<?php
/**
Pagina Inicial do projeto de diario online
*/

require_once("main.php");


require_once("PostsPeer.php");
require_once("MenuPeer.php");

$criteria = new Criteria();
$criteria->addAscendingOrderByColumn(MenuPeer::IDMENU);
$menus = MenuPeer::doSelect($criteria);
$marray = array();
foreach($menus as $menu) {
    $marray[] = $menu->toArray();
}


$criteria = new Criteria();
$criteria->addDescendingOrderByColumn(PostsPeer::IDPOSTS);
$posts = PostsPeer::doSelect($criteria);
$parray = array();
$tarray = array();
$n = 0;
foreach($posts as $post) {
    $qntcomentarios = $post->countComentarioss();
    $parray[$n] = $post->toArray();
    $parray[$n][qntcomentarios] = $qntcomentarios;
    $tags = $post->getTags();
    if($tags!=null){
      $parray[$n][tags] = $tags->toArray();
    }
    $n++;
}

$pagina->assign('posts',$parray);
$pagina->assign('menus',$marray);

//echo "$<br />";
/*
echo "<pre>";
var_dump ($tags);
echo "</pre>";
*/



$pagina->display("index.tpl");

?>